export const AUTH_ERROR_TYPES = {
  USER_NOT_FOUND: 'USER_NOT_FOUND',
  INVALID_PASSWORD: 'INVALID_PASSWORD',
  USERNAME_EXISTS: 'USERNAME_EXISTS',
  EMAIL_EXISTS: 'EMAIL_EXISTS',
  REGISTRATION_FAILED: 'REGISTRATION_FAILED',
  UNAUTHORIZED: 'UNAUTHORIZED',
  FORBIDDEN: 'FORBIDDEN',
} as const;

export type AuthErrorType = typeof AUTH_ERROR_TYPES[keyof typeof AUTH_ERROR_TYPES];

export interface AuthError {
  type: 'auth' | 'network' | 'validation';
  code: AuthErrorType | string;
}

export interface LoginResponse {
  id: string;
  username: string;
  token: string;
  role: string;
}

export interface RegisterResponse {
  message: string;
}

export interface UserProfile {
  id: string;
  username: string;
  email: string;
  role: string;
  level: number;
  points: number;
  experience: number; // 用户经验值
  passkey: string; // 用户邀请码
  shareRatio: number;
  uploadSize: number;
  downloadSize: number;
  createdAt: string;
  lastActive: string;
  avatar: string;
  status: 'active' | 'banned';
}

export interface UserListResponse {
  users: UserProfile[];
  total: number;
  page: number;
  pageSize: number;
}

export interface PointsTransaction {
  id: string;
  userId: string;
  type: 'upload' | 'download' | 'bonus' | 'penalty';
  points: number;
  description: string;
  createdAt: string;
}